$(function() {
	$('.link').popup({
	    position:'bottom center'
	  })
	;
	$('.selection.dropdown').dropdown();
	
	$('.browse').popup({
		inline : true,
		hoverable : true,
		position : 'right center',
	});
	
	$("div.checkbox").checkbox();
	var checkAll = $("#checkAll");
	var itemCheck = $(".item-check");

	checkAll.on("change", function() {
		// 获取全选框选中状态
		itemCheck.prop("checked", this.checked)
	});

	itemCheck.on("change", function() {
		// 判断判断选中的个数是否和所有存在个数一样
		var checkeds = $(".item-check:checked");
		// 修改checkAll的checked属性
		checkAll.prop("checked", checkeds.length == itemCheck.length);
	});

	// 批量删除按钮事件
	$('#delete').on('click', function() {
		// 获取所有选中
		var checkeds = $(".item-check:checked");
		if (checkeds.length && confirm("确认要删除所有选中行吗？")) {
			// 获取所有选择的id
			var ids = [];
			checkeds.each(function() {
				ids.push(this.value);
			});
			// /../teacher/student/delete?id=ids
			location.replace("employee/delete?eid=" + ids.join("&eid="));
		}
	});
});

function dow(){
	$('.ui.labeled.icon.sidebar')
		.sidebar('setting', 'transition','overlay')
		.sidebar('toggle');
}

function logout(){
	var isLog = confirm("你确定要注销吗？");
	if(isLog){
		location.replace("logout.jsp");
	}
}

function cancle(){
	$('.ui.modal').modal('hide');
}

function allocation(){
	var checkeds = $(".item-check:checked");
	if (checkeds.length == 0) {
		alert("请选择要分配的学生!");
	} else {
		$('.ui.modal').modal('show');
		$('.ui.accordion').accordion({
			onChange : function() {
				var sids = [];
				checkeds.each(function() {
					sids.push(this.value);
				});
				//alert(sids);
				$('.content p').on('click', function(){ 
					var cid = $(this).attr('id');
					var ctype = $(this).children("input").val();
					//alert(cid);
					$('#btn_yes').on('click', function(){
						location.replace("class/already/allocation?sids="+cid+"&sids="+ctype+"&sids=" + sids.join("&sids="));
					});
				});
			}
		});
	}
}

function mOver(obj){ 
	obj.style.backgroundColor="#6699FF";
}
function mOut(obj){ 
	obj.style.backgroundColor="#fff";
}

$(function() {
	$('.ui.floating.dropdown.labeled.icon.button').dropdown();
	$('.ui.teal.basic.button');
});



